	var pageNo=1;
	var totalPage=1;
var article = {
		getList:function(No){
			var html = [];
				$.post(window.ctx + '/sys/articleList?pageNo='+ No +'&time=new Date().getTime()',function(datas) {
					for (var i = 0; i < datas.list.length; i++) {
						var content = datas.list[i].content.substring(0,60) + '...';
						html.push('<li class="list clearfix">');
						html.push('		<div class="list-icon ">');
						html.push('			<a href="'+ window.ctx +'/sys/authorBlog?userId='+ datas.list[i].userId +'&pageNo=1">');
						html.push('				<img src="'+ window.ctx +'/'+ datas.list[i].photo +'" />'+ datas.list[i].userName);
						html.push('			</a>');
						html.push('		</div>');
						html.push('		<div class="list-tit">');
						html.push('			<h4><a href="'+ window.ctx +'/sys/getArticle?id='+ datas.list[i].id +'">'+ datas.list[i].title +'</a></h4>');
						html.push('			<p>'+ content +'</p>');
						html.push('			<p class="item">');
						html.push('				<span class="glyphicon glyphicon-th-large"></span><span class="classify">'+ datas.list[i].categoryName +'</span>');
						html.push('				<span class="glyphicon glyphicon-time"></span><span class="introduce-time">'+ datas.list[i].createTime +'</span>');
						html.push('				<span class="glyphicon glyphicon-eye-open"></span><span class="read"><span class="read-more">'+ datas.list[i].readTimes +'</span></span>');
						html.push('			</p>');
						html.push('		</div>');
						html.push('</li>');
						
					}
					$('#articleList').append(html.join(''));
					pageNo++;
					totalPage = datas.totalPage;
				}, 'json'); 
			}
	}
	/**
	*	懒加载
	*/
	// 滚动条总共高度(scrollHeight) = 滚动过的高度(scrollTop) + 屏幕的可见高度(windowHeight)
	var scrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
	var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	var flag = true;
	window.onscroll = function() {
		var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
		if((scrollHeight - (scrollTop + windowHeight)) <= 20 && flag) {
			flag=false;
			if(pageNo>totalPage){
				var html = [];
				$('#loadGif').hide();
				html.push('<div style="margin:0 auto"><h3>没有了...</h3></div>');
				$('#articleList').append(html.join(''));
			}else{
				console.info(pageNo)
				article.getList(pageNo);
				scrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
				flag=true;
			}
		}
	}
	
var articleRank = {
		allRankList :function(){
			$.post(window.ctx + '/sys/allRankList',function(data){
				if(data){
					var html = [];
					for (var i = 0; i < data.length; i++) {
						var title = data[i].title.substring(0,15)+'...';
						html.push('<li class="list-group-item">'+ (i+1) +'、'+ title +'<span class="badge">'+ data[i].readTimes +'</span></li>');
					}
					$('#articleRank').append(html.join(''));
				}
			});
		}
}	
	$(function(){
		article.getList(1);
		articleRank.allRankList();
	})
